/*************************************************************************
    > File Name: byteorder.c
    > Author: Xing.Dai
    > Mail: Xing.Dai@aliyun.com 
    > Created Time: 2017-03-29 23:38
 ************************************************************************/

#include<stdio.h>
#include "unp.h"


int main(int argc, char **argv)
{
	union{
		short s;
		char c[sizeof(short)];
	}un;

	un.s = 0x0102;
	printf("%s: ", CPU_VENDOR_OS);

	if(sizeof(short) == 2){
		if(un.c[0] == 0x01 && un.c[1] == 0x02){
			printf("Big-endian.\n");
		} else if(un.c[0] == 0x02 && un.c[1] == 0x01){
			printf("Little-endian.\n");
		} else {
			printf("unknown.\n");
		}
	} else {
		printf("sizeof(short) = %d.\n", sizeof(short));
	}

}
